package klk.shop.objects;

import java.util.Hashtable;

public abstract class ArticleList extends KLKObject {
	
	protected Hashtable<Integer, Article> articles;
	
	protected ArticleList() {
		articles = new Hashtable<Integer, Article>();
	}
	
	public Hashtable<Integer, Article> getArticles() {
		return articles;
	}

	public void setArticles(Hashtable<Integer, Article> articles) {
		this.articles = articles;
	}

	protected void add(Article a) {
		if (!articles.containsKey(a.getArticleId())) {
			articles.put(a.getArticleId(), a);
		} 
	}

	protected void remove(Article a) {
		if (articles.containsKey(a.getArticleId())) {
				articles.remove(a.getArticleId());
		}
	}
	
	/**
	 * Liefert ein Article Objekt anhand der Id
	 * @param id Artikel-Id
	 * @return Article oder null
	 */
	public Article get(int id)
	{
		if(articles.containsKey(id))
			return articles.get(id);
		else
			return null;
	}
	
	public abstract String toHtml(String path);
	public int count(){
		return articles.size();
	}
}
